package jmc.core.service.impl.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Properties;

public class CallRpg {
	
	public static void main(String[] args) {

		//Connection Variables
		/*
		String AS400_ADDRESS = "192.168.1.1";
		String AS400_USERNAME = "jmc";
		String AS400_PASSWORD = "jmc";
		String AS400_LIBRARY = "SASPERJAVA";
		*/
		
		String AS400_ADDRESS = "192.168.1.12";
		String AS400_USERNAME = "qsecofr";
		String AS400_PASSWORD = "c2259";
		String AS400_LIBRARY = "SASPERJAVA";

		try {

		//START: Connection Block
		Class.forName("ar.com.ibm.as400.access.AS400JDBCDriver");
		Properties prop = new Properties();
		prop.put("user", AS400_USERNAME);
		prop.put("password", AS400_PASSWORD);
		prop.put("prompt", "false");
		prop.put("errors", "full");
		Connection the400 = DriverManager.getConnection("jdbc:as400://" + AS400_ADDRESS + "/" + AS400_LIBRARY, prop);
		the400.setAutoCommit(true);
		//END: Connection Block
		Statement stmt = the400.createStatement();
		//START: Run only if the Stored Procedure does not already exist
		try {
		
		stmt.execute("CREATE PROCEDURE PRGSP3 " +
		"(IN REQKEY CHARACTER(10)) " +
		"RESULT SETS 0 " +
		"LANGUAGE SQL " +
		"SPECIFIC PRGSP3 " +
		"NOT DETERMINISTIC " +
		"MODIFIES SQL DATA " +
		"CALL " + "COINSEUTIL" + ". PDFQSND(REQKEY)");
		}
		catch (Exception ex) {
		ex.printStackTrace();
		
			//It already exists, do nothing
		}
		//END: Run only if the Stored Procedure does not already exist


		}
		catch (Exception ex) {
		ex.printStackTrace();
		}
		}
}
